package com.xyq.controller;

import com.xqy.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;
@RestController
public class UserController {
    @Autowired
    private RestTemplate restTemplate;
    //    private static final String REST_URL_PREFIX="http://localhost:8081/";
    private static final String REST_URL_PREFIX="http://SPRINGCLOUD-PROVIDER-USER/";
    @GetMapping("/cs/get")
    public User getUser(Integer userId){
        System.out.println("consumer.method:get");
        return restTemplate.getForObject(REST_URL_PREFIX+"get?userId="+userId,User.class);
    }
    @GetMapping("/cs/list")
    public List<User> getUserList(){
        System.out.println("consumer_80.list");
        return restTemplate.getForObject(REST_URL_PREFIX+"list", List.class);
    }
    @GetMapping("/cs/test")
    public String  getTest(){
        System.out.println("feign_consumer.list");
        return "it is test";
    }
}
